<?php	
    include('../libary/init_admin.php');
	if (check()) header('location:index.php');
	if ($_POST['submit']!='')
	{
		$user=$_POST['user'];
		$pass=$_POST['pass'];
		$sql="SELECT * FROM `user` WHERE `user_name`='$user' AND `user_password`='$pass'";
		$userinfo=mysql_fetch_assoc(mysql_query($sql));
		if ($userinfo['user_level']==1)
		{
			$_SESSION['alogin']['status']=1;
			$_SESSION['alogin']['id']=$userinfo['user_id'];
			$_SESSION['alogin']['user']=$userinfo['user_name'];
		 header('location:index.php');
		}
		else header('location:login.php');
	} 
	else{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Đăng nhập</title>
<link rel="stylesheet" href="template/css/style.css" type="text/css" />
</head>
<body id="bd" class="950 fs3" ><a name="Top" id="Top"></a>
<div id="login-logo"><img src="template/images/cailuongso.jpg" width="200px"/></div>
<br/>
<div align="center">
  <table width="340" border="0">
    <tr>
      <td width="98" align="center"><img src="image/lock.png" width="86" height="105"></td>
      <td width="226" valign="top">
      <form method="post" id="login-box">
        <table width="100%">
          <tr align="center">
            <td colspan="2" height="10px"></td>
          </tr>
          <tr>
            <td width="57px" height="25">Tài khoản</td>
            <td><input id="login-input" type="text" name="user"/></td>
          </tr>
          <tr>
            <td height="25">Mật khẩu</td>
            <td><input id="login-input" type="password" name="pass"/></td>
          </tr>
          <tr>
            <td colspan="2"><input type="submit" name="submit" value="Đăng nhập" id="login-button"/></td>
          </tr>
        </table>
      </form></td>
    </tr>
  </table>
</div>
</body>
</html>
<?php } ?>